package me.zhulu.cglib;

/**
 * Created with IntelliJ IDEA.
 * User: herosea
 * Date: 14-4-17
 * Time: 下午4:11
 * To change this template use File | Settings | File Templates.
 */
public class Client {

    // http://llying.iteye.com/blog/220452
    public static void main(String[] args) {
        TableDAO tableDao = TableDAOFactory.getInstance();
        doMethod(tableDao);

        haveAuth();
        haveNoAuth();

        haveAuthByFilter();
    }

    public static void haveAuthByFilter() {
        TableDAO tDao = TableDAOFactory.getAuthInstanceByFilter(new AuthProxy("张三"));
        doMethod(tDao);

        tDao = TableDAOFactory.getAuthInstanceByFilter(new AuthProxy("李四"));
        doMethod(tDao);
    }


    public static void haveAuth() {
        TableDAO tableDAO = TableDAOFactory.getAuthInstance(new AuthProxy("张三"));
        doMethod(tableDAO);
    }

    public static void haveNoAuth() {
        TableDAO tableDAO = TableDAOFactory.getAuthInstance(new AuthProxy("李四"));
        doMethod(tableDAO);
    }

    public static void doMethod(TableDAO dao) {
        dao.create();
        dao.query();
        dao.update();
        dao.delete();
    }
}
